﻿using FluentNHibernate.Mapping;

namespace ControleRepresentante.Logic.Models.Maps
{
    public class AttributeMap : MapBase<Attribute>
    {
        public AttributeMap()
        {
            Map(x => x.Name)
                .Not.Nullable();
            Map(x => x.Type)
                .CustomType(typeof(AttributeType))
                .Not.Nullable();
            References(x => x.Representante)
                .Cascade.None();
            HasMany(x => x.AttributeValues)
                .Inverse()
                .Access.PascalCaseField(Prefix.mUnderscore)
                .Cascade.AllDeleteOrphan();
            HasMany(x => x.AttributeIndexColumnPreferences)
                .Inverse()
                .Access.PascalCaseField(Prefix.mUnderscore)
                .Cascade.AllDeleteOrphan();
        }
    }
}